package com.orange.builderPatterns.pojo;


import lombok.Data;

/*
 * @Description: 皮包类
 */
@Data
public class MyPackage {
    //颜色
    private String color;
    //大小
    private String size;
    //材质
    private String material;



    //在内部创建一个构建者对象
    public static class MyPackageBuilder{
        //设置
        private String color;
        private String size;
        private String material;

        //是否要一个老师傅帮你手工打造
        private boolean isHandMade;

        //设置颜色
        public MyPackageBuilder setColor(String color){
            this.color = color;
            return this;
        }
        //设置大小
        public MyPackageBuilder setSize(String size){
            this.size = size;
            return this;
        }
        //设置材质
        public MyPackageBuilder setMaterial(String material){
            this.material = material;
            return this;
        }
        //是否需要老师傅手工打造
        public MyPackageBuilder setIsHandMade(boolean isHandMade){
            this.isHandMade = isHandMade;
            return this;
        }

        //创建皮包对象
        public MyPackage build(){
            MyPackage myPackage = new MyPackage();
            myPackage.setColor(color);
            myPackage.setSize(size);
            myPackage.setMaterial(material);
            if (isHandMade){
                //需要老师傅手工打造---那么我们将使用最好的材料为你定制，最好的颜色，最好的大小
                myPackage.setColor("最好的颜色");
                myPackage.setSize("最好的大小");
                myPackage.setMaterial("最好的材料");
            }
            return myPackage;
        }
    }
}
